package com.genius.unite_platform.storedevice.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.genius.adminmanager.other.entity.ResponseJson;
import com.genius.unite_platform.storedevice.service.StoreDeviceService;
import com.genius.workflow.log.ControllerLog;
import javax.servlet.http.HttpSession;
import com.alibaba.fastjson.JSONArray;


@Controller
public class StoreDeviceInsertController {
	@Autowired
    @Qualifier("StoreDeviceInsertService")
    private StoreDeviceService StoreDeviceInsertService;

	/**
	 * 跳转到新的新增页面
	 */
	//@RequiresPermissions("698c20f32ed147dcb756eb0342df2d48")
	@PostMapping("/storedevice/toInsert")
	public String toInsert(){	
		return "/views/unite_platform/storedevice/insert";
	}


	/**
	 * 添加操作
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@ControllerLog(description="新增门店陈列设备管理")
	@PostMapping("/storedevice/add")
	@ResponseBody
	public JSONObject add(@RequestBody JSONObject json,HttpSession session){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = StoreDeviceInsertService.add(json, response,session);
		return response;
	}

	/**
	 * 新增填充操作
	 */
	@PostMapping("/storedevice/getDevice")
	@ResponseBody
	public JSONObject getDevice(@RequestBody JSONObject json){
		JSONObject response = new JSONObject();
    	response.put(ResponseJson.code, 0);
    	response = StoreDeviceInsertService.getDevice(json, response);
		return response;
	}
	
	/**
	 * 新增填充操作
	 */
	@GetMapping("/storedevice/getStore")
	@ResponseBody
	public JSONArray getStore(String storeno){	
		 return  StoreDeviceInsertService.getStore(storeno);
	   
	}
	
	
}

